<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * This is the key class to all the admin side data nodes.
    * It is extended into child classes which do all the work.
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 03.08.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/
    
    /***
    * Class adminNodeContactform
    ****
    * This class handles the editing of simple contact form in INA
    ****
    * @package adminNodes
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 03.08.2005
    * @copyright essentialmind.com 2005
    ***/
    class adminNodeContactform extends adminNode{
        
		/**
         * a data processor.
         * 
         * @return 
         **/
        function process(){
            if($_POST){
                //update database record
                $this->db->Execute("UPDATE node_contactform SET content = '".addslashes($_POST['content'])."',  mailto = '".addslashes($_POST['mailto'])."' WHERE id = " . $this->object);
                
                //updates the status of the page (title, wf state)
                $this->updatePageStatus();
                
                //make a note of the ajax request
                $this->log->recordAction("Updated Contact Form (".$this->object.") with global id (".$this->pageref.")");
            
                header('Location: '.$this->request.'&confirm=true');
                exit;
            }else{
                $this->smarty->assign('page',$this->db->getRow("SELECT title, content, mailto FROM pagemap LEFT JOIN node_contactform ON pagemap.pageid = node_contactform.id WHERE pagemap.id = " . $this->pageref));
            }
        }
        
        /**
         * Will set the HTML template needed for
         * the child's operation
         * 
         * @return 
         **/
        function setTemplate(){
            $this->setActionTemplate('nodes/editContactform.html');
        }
        
        
		/** 
         * method which will handle a default add action to the
         * dedicated table
         * 
         * @return integer ID of new object
         * @see ajaxAddPage
         * @see ajaxAddNode
         **/
        function addInstance(){
            $this->db->Execute("INSERT INTO node_contactform(mailto, content) VALUES('".$GLOBALS['_CONFIG']['bot']."','')");
            return $this->db->getOne("SELECT last_value FROM node_contactform_id_seq");
        }
    }
?>